package cn.itsource.user.service.impl;

import cn.itsource.user.domain.User;
import cn.itsource.user.mapper.UserMapper;
import cn.itsource.user.service.IUserService;
import cn.itsource.basic.exception.CustomException;
import cn.itsource.basic.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class UserServiceImpl extends BaseServiceImpl<User> implements IUserService {
    @Autowired
    private UserMapper mapper;

    @Override
    public void checkPhone(String phone) throws CustomException {
      if (StringUtils.isEmpty(phone)){
          throw new CustomException("手机号不能为空！！");
      }
      User user = mapper.selectByPhone(phone);
      if(user!=null){
          throw new CustomException("手机号已注册！！");
      }
    }

    @Override
    public User loadByLogininfoid(Long id) {

        return mapper.loadByLogininfoid(id);
    }
}
